home *** CD-ROM | disk | FTP | other *** search
- ************************************************************************
- * GetLockName.asm - gets the name of a lock *
- * Written August 1988 by Talin *
- * Assembly version Oct 1988 by JPearce / Talin *
- ************************************************************************
-
- ; LONG GetLockName(lock,buffer,length)
-
- include 'macros.i'
- include 'exec/memory.i'
- include 'libraries/dosextens.i'
-
- public _DOSBase
-
- DECLARE GetLockName ; GetLockName(lock,buffer,length)
-
- SaveM a2/a3/d4
-
- moveq #0,d4 ; result = FALSE
-
- NEW a3,fib_SIZEOF ; get storage for FileInfoBlock
- tst.l d0
- beq.s scat1 ; out of memory error
-
- move.l 16(sp),d1 ; d1 <-- lock on object
- move.l a3,d2 ; d2 <-- address of FIB
- CallDos Examine ; d0 <-- success
- tst.l d0
- beq.s scat2 ; examine failed
-
- lea fib_FileName(a3),a1 ; a1 <-- address of filename
- move.l 20(sp),a0 ; a0 <-- address of buffer
- move.l 24(sp),d1 ; d1 <-- maximum name laength
- bra.s 2$ ; start looping
-
- 1$ move.b (a1)+,(a0)+ ; move 1 byte
- beq.s 3$ ; if NULL, then quit
- 2$ dbra d1,1$ ; loop until no more bytes
- 3$ move.b #0,-1(a0) ; make sure string NULL terminated!
- moveq #-1,d4 ; result = TRUE
-
- scat2: DELETE a3,fib_SIZEOF ; free memory
- scat1: move.l d4,d0 ; return result
- RestoreM a2/a3/d4
- rts
-
- end
-
- LONG GetLockName(LOCK lock,char *buffer,LONG length)
- { register struct FileInfoBlock *fib=NULL;
- register ULONG result = FALSE;
-
- unless (fib = AllocMem(sizeof *fib,MEMF_CLEAR)) /* create the file info block */
- return NULL;
- if (result = Examine(lock,fib)) /* examine file */
- strn_cpy(buffer,fib->fib_Name,length); /* fill in date */
- FreeMem(fib,sizeof *fib); /* de-alloc fib */
- return result;
- }
-